<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "user_patient_symptom".
 *
 * @property int $id
 * @property int $user_id 用户id
 * @property int $user_patient_id 用户患者id
 * @property string $symptom 症状
 * @property string $age 年龄(开药方时根据开方时期显示更新的年龄)
 * @property string $height 身高
 * @property string $weight 体重
 * @property string $temperature 体温
 * @property string $pulse 脉搏(心跳)
 * @property string $create_time 操作日期
 * @property int $status 状态
 *
 * @property User $user
 * @property UserPatient $userPatient
 * @property User $user0
 * @property UserPatient $userPatient0
 * @property UserRecipe[] $userRecipes
 */
class UserPatientSymptom extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user_patient_symptom';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id', 'user_patient_id', 'symptom'], 'required'],
            [['user_id', 'user_patient_id', 'status'], 'integer'],
            [['symptom'], 'string'],
            [['create_time'], 'safe'],
            [['age'], 'string', 'max' => 10],
            [['height', 'weight', 'temperature', 'pulse'], 'string', 'max' => 20],
            [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
            [['user_patient_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserPatient::className(), 'targetAttribute' => ['user_patient_id' => 'id']],
            [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
            [['user_patient_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserPatient::className(), 'targetAttribute' => ['user_patient_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'user_id' => '用户id',
            'user_patient_id' => '用户患者id',
            'symptom' => '症状',
            'age' => '年龄',
            'height' => '身高',
            'weight' => '体重',
            'temperature' => '体温',
            'pulse' => '脉搏(心跳)',
            'create_time' => '操作日期',
            'status' => '状态',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUserPatient()
    {
        return $this->hasOne(UserPatient::className(), ['id' => 'user_patient_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser0()
    {
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUserPatient0()
    {
        return $this->hasOne(UserPatient::className(), ['id' => 'user_patient_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUserRecipes()
    {
        return $this->hasMany(UserRecipe::className(), ['user_patient_symptom_id' => 'id']);
    }
}
